package 集合;

import java.util.Arrays;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int N = 100010;
    static boolean[] st = new boolean[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        int[] num = new int[n + m];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            st[a[i]] = true;
            num[cnt++] = a[i];
        }
        for (int i = 0; i < m; i++) {
            if (!st[b[i]]) {
                num[cnt++] = b[i];
            }
        }
        Arrays.sort(num,0,cnt);
        for (int i = 0; i < cnt; i++) {
            System.out.print(num[i]+" ");
        }
    }
}